<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        计算两个文本框的加减乘除

    文本框 + 文本框 按钮（=） 文本框（结果）
    </div>
    <input type="text" id="num1">
    <select name="" id="calc">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
    </select>
    <input type="text" id="num2">
    <button id="btn">计算</button>
    <input type="text" id="res">
    <script>
        var num1 = document.getElementById("num1");
        var num2 = document.getElementById("num2");
        var res = document.getElementById("res");
        var btn = document.getElementById("btn");
        var calc = document.getElementById("calc");
        var mm = 0;
        btn.onclick = function () {
            if ( calc.value == "+" ) {
                mm = parseFloat(num1.value) + parseFloat(num2.value);
            } else if ( calc.value == "-" ) {
                mm = num1.value - num2.value;
            } else if ( calc.value == "*" ) {
                mm = num1.value * num2.value;
            } else if ( calc.value == "/" ) {
                mm = num1.value / num2.value;
            }
            res.value = mm ;
        }
    </script>
</body>
</html>